import logging

from redis import StrictRedis


class Config:
    LOG_LEVEL = logging.DEBUG
    SQLALCHEMY_DATABASE_URI = 'mysql://root:mysql@127.0.0.1:3306/news_flask'
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # 为什么要把sql和redis的配置都当到config类中？
    REDIS_APP_IP = '127.0.0.1'
    REDIS_APP_PORT = 6379
    SESSION_TYPE = 'redis'
    SESSION_USE_SIGNER = True # ????
    # 我们这里使用os.urandom生成随机数,然后进行base64编码.
    SECRET_KEY = 'vT04U0YCU2hCMOhiAXGhURtgjv5f42OTDlpUnpLIavFB4ioO1jOpU6Uf/Rru92iUw+JJ1U4doDaKpJg9TeNalw=='

    SESSION_REDIS = StrictRedis(host=REDIS_APP_IP, port=REDIS_APP_PORT)
    SESSION_PERMANENT = False
    PERMANENT_SESSION_LIFETIME = 86400  # 在哪里啊？

class ProductConfig(Config):
    DEBUG = False
    LOG_LEVEL = logging.WARNING


class DevelopConfig(Config):
    DEBUG = True

class TestingConfig(Config):
    DEBUG = True
    TESTING = True # 开发模式下打印报错信息;

dict_config = {
    'PRODUCT':ProductConfig,
    'DEVELOP':DevelopConfig,
    'DTESTING':TestingConfig,
}